package logic

import (
	"context"
	"teacher1/model/mysql"

	"teacher1/studentrpc/internal/svc"
	"teacher1/studentrpc/studentrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type StudentAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewStudentAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StudentAddLogic {
	return &StudentAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *StudentAddLogic) StudentAdd(in *studentrpc.StudentAddRequest) (*studentrpc.StudentAddResponse, error) {
	// todo: add your logic here and delete this line
	student := mysql.Student{
		Number:    in.Number,
		IdCard:    in.IdCard,
		RealName:  in.RealName,
		Mobile:    in.Mobile,
		Job:       in.Job,
		HeadImg:   in.HeadImg,
		TeaCherId: in.TeaCherId,
	}
	mysql.DB.Debug().Create(&student)
	return &studentrpc.StudentAddResponse{Id: int64(student.ID)}, nil
}
